function Timer(functionName, delay)
{
  this._functionName = functionName;
  this._delay = delay;
  this._isStoped = false;
  this._isStarted = false;
}

Timer.prototype._functionName;
Timer.prototype._delay;
Timer.prototype._isStoped;
Timer.prototype._isStarted;
Timer._counter = 0;

Timer.prototype.start = function()
{
    if (this._isStarted)
    {
	    return;
    }

    this._isStoped = false;
    this._isStarted = true;

    var funcName = "id" + Timer._counter++;
    var thisPtr = this;
    scene[funcName] = function()
    {
	    if (!thisPtr._isStoped)
        {
	        scene[thisPtr._functionName]();
	    }
	    thisPtr._isStarted = false;
    };

    playByTimer(funcName, this._delay);
};

Timer.prototype.stop = function()
{
    this._isStoped = true;
};

var timer = new Timer("testFunc", 5000);

scene.testFunc = function() {
    traceStr("test function");
};

scene.testFunc2 = function() {
    timer.stop();
};

var cube = scene.getObjectByName("cube");
cube.onPress = function() {
    timer.start();
    playByTimer("testFunc2", 3000);
};
